package com.wx.commons.utils;

import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;

public class WebServiceUtil<T> {

    public T getRequestService(String url, Class<T> clazz) {
        JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
        // 设置代理地址
        jaxWsProxyFactoryBean.setAddress(url);
        // 设置接口类型
        jaxWsProxyFactoryBean.setServiceClass(clazz);
        // 创建一个代理接口实现
        return (T) jaxWsProxyFactoryBean.create();
    }

    public Client getClient(String url) {
        JaxWsDynamicClientFactory dcflient = JaxWsDynamicClientFactory.newInstance();
        Client client = dcflient.createClient(url);
        return client;
    }

}
